package com.mes.spc.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mes.spc.service.EmesqSpcChartViewService;
import com.mes.spc.service.EmesqSpcCheckItemConfigService;
import com.mes.spc.service.EmesqSpcControlChartService;
import com.mes.spc.util.SpcCalUtil;
import com.yy.base.page.Message;

/**
 * 控制图查看
 * @author xgh
 *
 */
@Controller
@RequestMapping("spc/chartView")
public class EmesqSpcChartViewController {
	@Autowired
    private EmesqSpcChartViewService emesqSpcChartViewService;
	@Autowired
    private EmesqSpcControlChartService emesqSpcControlChartService;
    @Autowired
    private EmesqSpcCheckItemConfigService esccs;

    @RequestMapping(value="xrChart", method=RequestMethod.POST)
    @ResponseBody
    public Message xrChart(HttpServletRequest request) {

        double[] avgArray = {1.93d,2.527d,2.894d,2.476d,2.256d,2.448d,2.467d,2.124d,2.986d,1.825d};//样本均值
        double[] avgRArray = {0.12d,0.72d,0.47d,1.13d,1.1d,1.98d,1.02d,0.37d,1.35d,0.79d};//组内极差
        int size = 5;//样本容量
        //基础数据
        double LSL = 1.00d;
        double USL = 5.000d;
        double target =3d;

        Message msg = new Message();
        String configId = request.getParameter("configId");
        String scDate = request.getParameter("scDate");//时间范围
        String isSample = request.getParameter("isSample");//是否为样本筛选
        String remark1 = request.getParameter("remark1");
		String remark2 = request.getParameter("remark2");
		String remark3 = request.getParameter("remark3");
		String remark4 = request.getParameter("remark4");
		String remark5 = request.getParameter("remark5");
		Map<String,String> paramMap = new HashMap<String, String>();
		if(remark1!=null)paramMap.put("remark1", remark1);
		if(remark2!=null)paramMap.put("remark2", remark2);
		if(remark3!=null)paramMap.put("remark3", remark3);
		if(remark4!=null)paramMap.put("remark4", remark4);
		if(remark5!=null)paramMap.put("remark5", remark5);
        
        if(StringUtils.isEmpty(configId))return msg;
        Map<String, Object> ckConfig = this.esccs.getSpcCkConfigById(configId);
        Map<String, Object> arrayDataMap = emesqSpcControlChartService.getSampleArrayData(ckConfig,configId,isSample!=null&&isSample.equals("1")?true:false,scDate,paramMap);
        if(checkData(arrayDataMap)){
            return msg;
        }
        avgArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgArray"));//样本均值
        avgRArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgRArray"));//极差平均值
        size = Integer.parseInt(ckConfig.get("SAMPLE_VOLUME")+"");//样本容量
        LSL = Double.parseDouble(ckConfig.get("SPECIFICA_LOWER")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("SPECIFICA_LOWER")+""));
        USL =  Double.parseDouble(ckConfig.get("SPECIFICA_UPPER")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("SPECIFICA_UPPER")+""));
        target = Double.parseDouble(ckConfig.get("TARGET_VAL")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("TARGET_VAL")+""));
        String[] stateArray = (String[])arrayDataMap.get("stateArray");
        
        Map<String, Double> calData = emesqSpcChartViewService.calXRChartData(avgArray,avgRArray,size,LSL,USL,target);
        msg.setData("calData", calData);
        msg.setData("avgArray",avgArray);
        msg.setData("avgRArray",avgRArray);
        msg.setData("stateArray",stateArray);
        getControlData(ckConfig, configId, calData, msg,paramMap);
        return msg;
    }

    @RequestMapping(value="xsChart", method=RequestMethod.POST)
    @ResponseBody
    public Message xsChart(HttpServletRequest request) {
        double[] avgArray = {24.544d,24.57d,24.566d,24.51d,24.514d,24.532d,24.522d,24.368d,24.526d,24.522d,24.492d,24.554d};//样本均值
        double[] avgRArray = {0.07d,0.21d,0.18d,0.16d,0.19d,0.14d,0.05d,0.16d,0.11d,0.11d,0.23d,0.15d};//组内极差
        double[] stdevArray = {0.0251d,0.082765d,0.073689d,0.061237d,0.083845d,0.058052d,0.021679d,0.066106d,0.043932d,0.042071d,0.091488d,0.057706};//组内标准差
        int size = 5;//样本容量
        //基础数据
        double LSL = 24.300d;
        double USL = 24.700d;
        double target = 24.5d;

        Message msg = new Message();
        String configId = request.getParameter("configId");
        String scDate = request.getParameter("scDate");//时间范围
        String isSample = request.getParameter("isSample");//是否为样本筛选
        String remark1 = request.getParameter("remark1");
		String remark2 = request.getParameter("remark2");
		String remark3 = request.getParameter("remark3");
		String remark4 = request.getParameter("remark4");
		String remark5 = request.getParameter("remark5");
		Map<String,String> paramMap = new HashMap<String, String>();
		if(remark1!=null)paramMap.put("remark1", remark1);
		if(remark2!=null)paramMap.put("remark2", remark2);
		if(remark3!=null)paramMap.put("remark3", remark3);
		if(remark4!=null)paramMap.put("remark4", remark4);
		if(remark5!=null)paramMap.put("remark5", remark5);
        if(StringUtils.isEmpty(configId))return msg;
        Map<String, Object> ckConfig = this.esccs.getSpcCkConfigById(configId);
        Map<String, Object> arrayDataMap = emesqSpcControlChartService.getSampleArrayData(ckConfig,configId,isSample!=null&&isSample.equals("1")?true:false,scDate,paramMap);
        if(checkData(arrayDataMap)){
            return msg;
        }

        avgArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgArray"));//样本均值
        avgRArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgRArray"));//极差平均值
        stdevArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgStdevArray"));//标准差均值
        LSL = Double.parseDouble(ckConfig.get("SPECIFICA_LOWER")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("SPECIFICA_LOWER")+""));
        USL =  Double.parseDouble(ckConfig.get("SPECIFICA_UPPER")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("SPECIFICA_UPPER")+""));
        target = Double.parseDouble(ckConfig.get("TARGET_VAL")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("TARGET_VAL")+""));

        Map<String, Double> calData = emesqSpcChartViewService.calXSChartData(avgArray,avgRArray,stdevArray,size,LSL,USL,target);

        msg.setData("calData", calData);
        msg.setData("avgArray",avgArray);
        msg.setData("stdevArray",stdevArray);
        getControlData(ckConfig, configId, calData, msg,paramMap);
        return msg;
    }

    @RequestMapping(value="imrChart", method=RequestMethod.POST)
    @ResponseBody
    public Message imrChart(HttpServletRequest request) {
        double[] avgArray = {0.72d,0.55d,0.63d,0.58d,0.66d,0.58d,0.35d,0.55d,0.66d,0.57d,0.62d,0.87d};//样本均值
        double[] avgRArray = {0d,0.17d,0.08d,0.05d,0.08d,0.08d,0.23d,0.2d,0.11d,0.09d,0.05d,0.25d};//极差平均值
        int size = 1;//样本容量
        //基础数据
        Double USL = 1.000d;
        Double target = SpcCalUtil.ErrNum;
        Double LSL = SpcCalUtil.ErrNum;

        Message msg = new Message();
        String configId = request.getParameter("configId");
        String scDate = request.getParameter("scDate");//时间范围
        String isSample = request.getParameter("isSample");//是否为样本筛选
        String remark1 = request.getParameter("remark1");
		String remark2 = request.getParameter("remark2");
		String remark3 = request.getParameter("remark3");
		String remark4 = request.getParameter("remark4");
		String remark5 = request.getParameter("remark5");
		Map<String,String> paramMap = new HashMap<String, String>();
		if(remark1!=null)paramMap.put("remark1", remark1);
		if(remark2!=null)paramMap.put("remark2", remark2);
		if(remark3!=null)paramMap.put("remark3", remark3);
		if(remark4!=null)paramMap.put("remark4", remark4);
		if(remark5!=null)paramMap.put("remark5", remark5);
        if(StringUtils.isEmpty(configId))return msg;
        Map<String, Object> ckConfig = this.esccs.getSpcCkConfigById(configId);
        Map<String, Object> arrayDataMap = emesqSpcControlChartService.getSampleArrayData(ckConfig,configId,isSample!=null&&isSample.equals("1")?true:false,scDate,paramMap);
        if(checkData(arrayDataMap)){
            return msg;
        }
        avgArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgArray"));//样本均值
        avgRArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgRArray"));//极差平均值
        size = Integer.parseInt(ckConfig.get("SAMPLE_VOLUME")+"");//样本容量
        LSL = Double.parseDouble(ckConfig.get("SPECIFICA_LOWER")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("SPECIFICA_LOWER")+""));
        USL =  Double.parseDouble(ckConfig.get("SPECIFICA_UPPER")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("SPECIFICA_UPPER")+""));
        target = Double.parseDouble(ckConfig.get("TARGET_VAL")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("TARGET_VAL")+""));

        Map<String, Double> calData = emesqSpcChartViewService.calIMRChartData(avgArray,avgRArray,size,LSL,USL,target);
        msg.setData("calData", calData);
        msg.setData("avgArray",avgArray);
        msg.setData("avgRArray",avgRArray);
        getControlData(ckConfig, configId, calData, msg,paramMap);
        return msg;
    }

    @RequestMapping(value="cpkChart", method=RequestMethod.POST)
    @ResponseBody
    public Message cpkChart(HttpServletRequest request) {
        double[] avgArray = {1.93f,2.527f,2.894f,2.476f,2.256f,2.448f,2.467f,2.124f,2.986f,1.825f};//样本均值
        double[] avgRArray = {0.12f,0.72f,0.47f,1.13f,1.1f,1.98f,1.02f,0.37f,1.35f,0.79f};//极差平均值
        int size = 3;//样本容量
        double LSL = 1.000f;
        double USL = 4.000f;
        double target = 2.5f;
        double[] arrData = {
                1.88f,2f,1.91f,
                2.4f,2.23f,2.95f,
                3.2f,2.75f,2.73f,
                2.63f,2.97f,1.83f,
                1.69f,2.79f,2.29f,
                3.67f,1.99f,1.69f,
                2.27f,3.076f,2.06f,
                2.25f,1.88f,2.24f,
                2.17f,3.27f,3.52f,
                1.65f,2.31f,1.52f

        };//样本

        Message msg = new Message();
        String configId = request.getParameter("configId");
        String scDate = request.getParameter("scDate");//时间范围
        String isSample = request.getParameter("isSample");//是否为样本筛选
        String remark1 = request.getParameter("remark1");
		String remark2 = request.getParameter("remark2");
		String remark3 = request.getParameter("remark3");
		String remark4 = request.getParameter("remark4");
		String remark5 = request.getParameter("remark5");
		Map<String,String> paramMap = new HashMap<String, String>();
		if(remark1!=null)paramMap.put("remark1", remark1);
		if(remark2!=null)paramMap.put("remark2", remark2);
		if(remark3!=null)paramMap.put("remark3", remark3);
		if(remark4!=null)paramMap.put("remark4", remark4);
		if(remark5!=null)paramMap.put("remark5", remark5);
        if(StringUtils.isEmpty(configId))return msg;
        Map<String, Object> ckConfig = this.esccs.getSpcCkConfigById(configId);
        Map<String, Object> arrayDataMap = emesqSpcControlChartService.getSampleArrayData(ckConfig,configId,isSample!=null&&isSample.equals("1")?true:false,scDate,paramMap);
        if(checkData(arrayDataMap)){
            return msg;
        }
        avgArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgArray"));//样本均值
        avgRArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgRArray"));//极差平均值
        arrData = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("arrData"));//所有样本
        double[] stdevArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgStdevArray"));//标准差均值
        size = Integer.parseInt(ckConfig.get("SAMPLE_VOLUME")+"");//样本容量
        LSL = Double.parseDouble(ckConfig.get("SPECIFICA_LOWER")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("SPECIFICA_LOWER")+""));
        USL =  Double.parseDouble(ckConfig.get("SPECIFICA_UPPER")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("SPECIFICA_UPPER")+""));
        target = Double.parseDouble(ckConfig.get("TARGET_VAL")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("TARGET_VAL")+""));

        Map<String, Object> calData = emesqSpcChartViewService.cpkAnalysis(arrData,avgArray,avgRArray,stdevArray,size,USL,LSL,target);
        msg.setData(calData);
        return msg;
    }

    @RequestMapping(value="normalCheck", method=RequestMethod.POST)
    @ResponseBody
    public Message normalCheck(HttpServletRequest request) {
        double[] arrData = {
                1.88d,2d,1.91d,
                2.4d,2.23d,2.95d,
                3.2d,2.75d,2.73d,
                2.63d,2.97d,1.83d,
                1.69d,2.79d,2.29d,
                3.67d,1.99d,1.69d,
                2.27d,3.076d,2.06d,
                2.25d,1.88d,2.24d,
                2.17d,3.27d,3.52d,
                1.65d,2.31d,1.52d

        };//样本
        double[] avgArray = {1.93f,2.527f,2.894f,2.476f,2.256f,2.448f,2.467f,2.124f,2.986f,1.825f};//样本均值
        Message msg = new Message();
        String configId = request.getParameter("configId");
        String scDate = request.getParameter("scDate");//时间范围
        String isSample = request.getParameter("isSample");//是否为样本筛选
        String remark1 = request.getParameter("remark1");
		String remark2 = request.getParameter("remark2");
		String remark3 = request.getParameter("remark3");
		String remark4 = request.getParameter("remark4");
		String remark5 = request.getParameter("remark5");
		Map<String,String> paramMap = new HashMap<String, String>();
		if(remark1!=null)paramMap.put("remark1", remark1);
		if(remark2!=null)paramMap.put("remark2", remark2);
		if(remark3!=null)paramMap.put("remark3", remark3);
		if(remark4!=null)paramMap.put("remark4", remark4);
		if(remark5!=null)paramMap.put("remark5", remark5);
        if(StringUtils.isEmpty(configId))return msg;
        Map<String, Object> ckConfig = this.esccs.getSpcCkConfigById(configId);
        Map<String, Object> arrayDataMap = emesqSpcControlChartService.getSampleArrayData(ckConfig,configId,isSample!=null&&isSample.equals("1")?true:false,scDate,paramMap);
        if(checkData(arrayDataMap)){
            return msg;
        }
        avgArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgArray"));//样本均值
        arrData = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("arrData"));//所有样本

        Map<String, Object> normalCheckArray = emesqSpcChartViewService.normalCheck(arrData,avgArray);
        msg.setData(normalCheckArray);
        return msg;
    }

    @RequestMapping(value="cpkPredit", method=RequestMethod.POST)
    @ResponseBody
    public Message cpkPredit(HttpServletRequest request) {
        double[] avgArray = {1.93f,2.527f,2.894f,2.476f,2.256f,2.448f,2.467f,2.124f,2.986f,1.825f};//样本均值
        double[] avgRArray = {0.12f,0.72f,0.47f,1.13f,1.1f,1.98f,1.02f,0.37f,1.35f,0.79f};//极差平均值
        int size = 3;//样本容量
        double LSL = 1.000f;
        double USL = 4.000f;

        Message msg = new Message();
        String configId = request.getParameter("configId");
        String scDate = request.getParameter("scDate");//时间范围
        String isSample = request.getParameter("isSample");//是否为样本筛选
        String remark1 = request.getParameter("remark1");
		String remark2 = request.getParameter("remark2");
		String remark3 = request.getParameter("remark3");
		String remark4 = request.getParameter("remark4");
		String remark5 = request.getParameter("remark5");
		Map<String,String> paramMap = new HashMap<String, String>();
		if(remark1!=null)paramMap.put("remark1", remark1);
		if(remark2!=null)paramMap.put("remark2", remark2);
		if(remark3!=null)paramMap.put("remark3", remark3);
		if(remark4!=null)paramMap.put("remark4", remark4);
		if(remark5!=null)paramMap.put("remark5", remark5);
        if(StringUtils.isEmpty(configId))return msg;
        Map<String, Object> ckConfig = this.esccs.getSpcCkConfigById(configId);
        Map<String, Object> arrayDataMap = emesqSpcControlChartService.getSampleArrayData(ckConfig,configId,isSample!=null&&isSample.equals("1")?true:false,scDate,paramMap);
        if(checkData(arrayDataMap)){
            return msg;
        }
        avgArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgArray"));//样本均值
        avgRArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgRArray"));//极差平均值
        size = Integer.parseInt(ckConfig.get("SAMPLE_VOLUME")+"");//样本容量
        LSL = Double.parseDouble(ckConfig.get("SPECIFICA_LOWER")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("SPECIFICA_LOWER")+""));
        USL =  Double.parseDouble(ckConfig.get("SPECIFICA_UPPER")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("SPECIFICA_UPPER")+""));

        Map<String, Object> cpkArray = emesqSpcChartViewService.cpkPredit(avgArray,avgRArray,size,USL,LSL);
        msg.setData(cpkArray);
        return msg;
    }
    
    @RequestMapping(value="cpkCyclePredit", method=RequestMethod.POST)
    @ResponseBody
    public Message cpkCyclePredit(HttpServletRequest request) {
        double[] avgArray = {1.93f,2.527f,2.894f,2.476f,2.256f,2.448f,2.467f,2.124f,2.986f,1.825f};//样本均值
        double[] avgRArray = {0.12f,0.72f,0.47f,1.13f,1.1f,1.98f,1.02f,0.37f,1.35f,0.79f};//极差平均值
        int size = 3;//样本容量
        double LSL = 1.000f;
        double USL = 4.000f;

        Message msg = new Message();
        String configId = request.getParameter("configId");
        String scDate = request.getParameter("searchDate");//时间范围
        String searchType = request.getParameter("searchType");
        String cycleHour = request.getParameter("cycleHour");//周期
        String remark1 = request.getParameter("remark1");
		String remark2 = request.getParameter("remark2");
		String remark3 = request.getParameter("remark3");
		String remark4 = request.getParameter("remark4");
		String remark5 = request.getParameter("remark5");
		Map<String,String> paramMap = new HashMap<String, String>();
		if(remark1!=null)paramMap.put("remark1", remark1);
		if(remark2!=null)paramMap.put("remark2", remark2);
		if(remark3!=null)paramMap.put("remark3", remark3);
		if(remark4!=null)paramMap.put("remark4", remark4);
		if(remark5!=null)paramMap.put("remark5", remark5);
        if(StringUtils.isEmpty(configId))return msg;
        Map<String, Object> ckConfig = this.esccs.getSpcCkConfigById(configId);
        Map<String, Object> arrayDataMap = emesqSpcChartViewService.getCycleSampleData(configId,searchType, scDate,cycleHour,paramMap);
        if(checkData(arrayDataMap)){
            return msg;
        }
        avgArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgArray"));//样本均值
        avgRArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("avgRArray"));//极差平均值
        double[] stdArray = ArrayUtils.toPrimitive((Double[])arrayDataMap.get("stdArray"));//标准差
        String[] dateArray = (String[])arrayDataMap.get("dateArray");//日期横轴
        size = Integer.parseInt(ckConfig.get("SAMPLE_VOLUME")+"");//样本容量
        LSL = Double.parseDouble(ckConfig.get("SPECIFICA_LOWER")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("SPECIFICA_LOWER")+""));
        USL =  Double.parseDouble(ckConfig.get("SPECIFICA_UPPER")==null?SpcCalUtil.ErrNum +"":(ckConfig.get("SPECIFICA_UPPER")+""));

        Map<String, Object> cpkArray = emesqSpcChartViewService.cpkCyclePredit(avgArray,avgRArray,stdArray,size,USL,LSL);
        msg.setData(cpkArray);
        msg.put("dateArray", dateArray);
        return msg;
    }
    
    private boolean checkData(Map<String, Object> arrayDataMap){
        return arrayDataMap==null||Integer.parseInt(arrayDataMap.get("dataSize")+"")==0;
    }
    
    private void getControlData(Map<String, Object> ckConfig,String configId,Map<String, Double> calData1,Message msg,Map<String,String> paramMap){
    	//获取样本数据的控制限上下值
        String cxu = ckConfig.get("CONTROL_X_UPPER")==null?"":(ckConfig.get("CONTROL_X_UPPER")+"");
        String cxl = ckConfig.get("CONTROL_X_LOWER")==null?"":(ckConfig.get("CONTROL_X_LOWER")+"");
        String cx = ckConfig.get("CONTROL_X_VAL")==null?"":(ckConfig.get("CONTROL_X_VAL")+"");
        //如果未查到相关设置的控制上限，则根据样本重新计算上下限
        if(StringUtils.isEmpty(cxu)&&StringUtils.isEmpty(cxl)&&StringUtils.isEmpty(cx)){
        	try {
        		Map<String, Object> calData = esccs.calControl(configId,paramMap);
        		cxu = (Double)calData.get("UCL")==0d?"":(calData.get("UCL")+"");
        		cxl = (Double)calData.get("LCL")==0d?"":(calData.get("LCL")+"");
        		cx = (Double)calData.get("CL")==0d?"":(calData.get("CL")+"");
			} catch (Exception e) {
				
			}
        }
        //无样本数据则以当前数据进行计算
        if(StringUtils.isEmpty(cxu)&&StringUtils.isEmpty(cxl)&&StringUtils.isEmpty(cx)){
        	cxu = calData1.get("UCL_X")+"";
        	cxl = calData1.get("LCL_X")+"";
        	cx = calData1.get("CL_X")+"";
        }
        calData1.put("UCL_X", Double.parseDouble(cxu));
        calData1.put("LCL_X", Double.parseDouble(cxl));
        calData1.put("CL_X", Double.parseDouble(cx));
        
        calData1.put("maxArrayX",SpcCalUtil.max(new double[]{calData1.get("maxArrayX"),Double.parseDouble(cxu)}));
        calData1.put("minArrayX",SpcCalUtil.min(new double[]{calData1.get("minArrayX"),Double.parseDouble(cxl)}));
        
        msg.setData("cxu", SpcCalUtil.ZeroFormat(Double.parseDouble(cxu), 3));
        msg.setData("cxl", SpcCalUtil.ZeroFormat(Double.parseDouble(cxl), 3));
        msg.setData("cx", SpcCalUtil.ZeroFormat(Double.parseDouble(cx), 3));
    }
}
